package com.inossem.warehousestorage_inossem.request.outStorage;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStorageAllocatingOverviewBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * 作者：wsy on 2017/12/5 10:11
 * <p>
 * 邮箱：445979770@qq.com
 */

public class OutStorageAllocatingOverviewRequest extends Request {

    private static final String TRANSFER_NUMBER = "allocate_id";//调拨单号
    private static final String DELIVERY_NUMBER = "allocate_delivery_id";//配送单号

    public static String request(Context context, String transferNumber , String deliveryNumber, GsonBeanListener gsonBeanListener) {
        String tag;
        Map<String, String> params = new HashMap<>();
        params.put(TRANSFER_NUMBER, transferNumber);
        params.put(DELIVERY_NUMBER, deliveryNumber);
        String url = RequestManage.getUrl(context, RequestConstant.URL_OUT_STORAGE_ALLOCATING_OVERVIEW + RequestManage.mapEncodeToParams(params));
        tag = RequestManage.getHttpsGetWithLoading(context, url, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                OutStorageAllocatingOverviewBean bean = gson.fromJson(stringRequestResponse.getResponseInfo(), OutStorageAllocatingOverviewBean.class);
                excuteJsonBeanNew(context, bean, gsonBeanListener);
            }
        });
        return tag;
    }
}
